<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<html>
	<head>
		<title>获取待办任务</title>
		<%@ include file="/common/meta.jsp"%>
		<%@ include file="/common/jquery-ui-inc.jsp"%>
	</head>
	<script type="text/javascript" src="${ctx}/js/date.js"></script>
	<script>
		$(function() {
			$('#sysList').datagrid( {
				title : '待办任务列表',
				url : '${ctx}/flow/core/flow-task!approveData.action',
				loadMsg : '数据载入中,请稍后...',
				nowrap : false,
				collapsible : false,
				fitColumns : true,
				pagination : true,
				singleSelect : true,
				rownumbers : true,
				remoteSort : false,
				pageList : [ 10, 20, 30 ],
				idField : 'sysId',
				columns : [ [ {
					field : 'name',
					title : '任务名称',
					width : 120,
					sorter : function(a, b) {
						return (a > b ? 1 : -1);
					}
				}, {
					field : 'formResourceName',
					title : '系统URL',
					width : 400,
					sorter : function(a, b) {
						return (a > b ? 1 : -1);
					}
				}, {
					field : 'id',
					title : '任务Id',
					width : 100,
					sorter : function(a, b) {
						return (a > b ? 1 : -1);
					}
				}, {
					field : 'processInstanceId',
					title : '流程实例Id',
					width : 170
				},{
					field : 'createTime',
					title : '创建时间',
					width : 80,
					sorter : function(a, b) {
						return (a > b ? 1 : -1);
					}
				}, {
					title : '流程操作',
					field : 'cz',
					width : 150,
					align:'center',
					formatter:function(value,row,index){
						var returninfo= '<a href="javascript:viewProcessPic(\''+row.processInstanceId+'\')" >查看流程图</a> &nbsp;&nbsp;<a href="javascript:approve(\''+row.id+'\',\''+row.processInstanceId+'\')">审批</a>';
					 	return returninfo;
					}
				}] ],
		
				toolbar : [  '-',{
					text : '刷新',
					iconCls : 'icon-computer_go',
					handler : function() {
						reload();
					}
				}]
			});
		});

	function reload(){
		$('#sysList').datagrid('reload');
	}
		
	function lockQuery(){					
	    var queryParams = $('#sysList').datagrid('options').queryParams;
	      queryParams.assignEname = $('#userEname').val();
	      reload(); 
	 }
	  
	function clearQuery(){					
	    $('#userEname').val('');
	    lockQuery(); 
	 }
	 
	 
	function closeAddWin(){
		$('#approveWin').window('close');
	}

	function approve(id,processInstanceId){
		$('#approveFrame').html('');
		var url = '${ctx}/flow/core/flow-test!toApprove.action?taskId='+id+'&processInstanceId='+processInstanceId;
		$('#approveFrame').attr("src", url);
		$('#approveWin').window('open');
	}
	
	//查看流程图
	function viewProcessPic(id){
		var url = "${ctx}/flow/core/flow-view-pic.action?processInsId="+id;
		$("#testAddFrame").attr("src",url);
		$('#testAddWin').window('open');
	}
	
	</script>
	<body>
		
		<table class="datagrid-body">
			<tr>
				<td class="datagrid-header">
					用户名
				</td>
				<td>
					<input name="userEname" id="userEname" value=""/>
				</td>
				<td>
					<a class="easyui-linkbutton" iconCls="icon-search" onclick="lockQuery();">查询</a>
					<a class="easyui-linkbutton" iconCls="" onclick="clearQuery();">清空</a>
				</td>
			</tr>
		</table>
		<div class="demo-info">
			<div class="demo-tip icon-tip"></div>
			<div><font color="#F00" style="font-family:'楷体';" size="4">A.默认情况下,查询当前登录用户待办任务,如需要查询其他人待办任务,需要进行查询操作!</font></div>
			<span><font color="black" style="font-family:'楷体';" size="4">B.结束流程等待状态:在浏览器中执行链接：工作流访问路径+"/flow/core/flow-webservice!overState.action?processInsId="+实例id</font></span>
		</div>
		<table id="sysList"></table>
		
		<div id="approveWin" class="easyui-window" title="审批页面" style="padding: 0px; width: 530px; height: 300px;" iconCls="icon-computer_link" closed="true" maximizable="false" minimizable="false" collapsible="false">
			<iframe frameborder="0" id="approveFrame" height="100%" width="100%" scrolling="no" ></iframe>
		</div>
		
		<div id="testAddWin" class="easyui-window" title="查看流程图"
			style="padding: 5px; width: 1000px; height: 500;" 
			iconCls="icon-search" closed="true" maximizable="false"
			minimizable="false" collapsible="false" >
			<iframe frameborder="0" id="testAddFrame" height="100%" width="100%"
				scrolling="yes" frameborder="0" style="position:relative;"></iframe>
		</div>
	</body>
</html>